// app.js
import GoEasy from './utils/goeasy.min.js'
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    wx.cloud.init({
      env:'cemenghui-6g9l3a3q3d142d2e',
      traceUser:true,
    })
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
    
    this.globalData= {
      goEasy: "",
      user_id: "",  //存储用户登录时手机号
    }

    this.globalData.goEasy = GoEasy.getInstance({
      host: 'hangzhou.goeasy.io', //新加坡host：singapore.goeasy.io
      appkey: 'BC-93b859463fe44ef9b5c6202a5269ed9d', //替换为您的应用appkey
      modules: ['pubsub']
    });

    //建立连接
    this.globalData.goEasy.connect({
      onSuccess: function () { //连接成功
        console.log("GoEasy connect successfully.") //连接成功
      },
      onFailed: function (error) { //连接失败
        console.log("Failed to connect GoEasy, code:" + error.code + ",error:" + error.content);
      }
    });
  },

})